package cn.codergege.demo.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Profile;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseBuilder;
import org.springframework.jdbc.datasource.embedded.EmbeddedDatabaseType;

import javax.sql.DataSource;


@Profile({"development", "test"})
@Configuration
public class DevDataSourceConfig implements DataSourceConfig {

    @Override
    @Bean
    public DataSource createDataSource() {
        System.out.println("----> development, test: dataSource ");
        return new EmbeddedDatabaseBuilder()
                .setType(EmbeddedDatabaseType.H2)
                // .addScript("classpath:sql/h2-schema.sql")
                // .addScript("classpath:sql/h2-test-data.sql")
                .build();
    }
}
			